package face.yuque;

/**
 * @author spf
 * @date 2024/12/12
 * @time 21:37
 */
//斐波那契数列
//方法二：去重递归
public class FBNQ2 {

    public static void main(String[] args) {
        System.out.println(fbnq(10));
    }

    private static int fbnq(int n) {
        int[] arr = new int[n + 1];
        if (n == 0) {
            return 0;
        }
        if (n == 1) {
            return 1;
        }
        if (arr[n] != 0) {
            return arr[n];
        }
        arr[n] = fbnq(n - 1) + fbnq(n - 2);
        return arr[n];
    }

}
